<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- ## 4. aabccd，去掉重复的字符，使结果显示 abcd -->
    <script>
        var str='aabccd';
        var res=str.split("");
        var res1=res.reduce(function(pre,cur){
            if(pre.indexOf(cur)===-1){
                console.log(cur)
                return pre.concat(cur);
            }else{
                return pre;
            }
        },[])
        
        
    </script>
</body>

</html>